---
description:
  GraphQL Inspector Action checks your Pull Request to find breaking changes (and others) in a
  GraphQL Schema, against your `master` branch.
---

import { Callout } from '@theguild/components'

# GitHub Action

[GraphQL Inspector Action](https://github.com/marketplace/actions/graphql-inspector) is a GitHub
Action that you can install in any of your repositories.

GraphQL Inspector Action checks your Pull Request to find breaking changes (and others) in a GraphQL
Schema, against your `master` branch.

![Application](/assets/img/github/app-action.jpg)

## Usage

```yaml
name: CI

on: [push]

jobs:
  test:
    name: Check Schema
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@master

      - uses: graphql-hive/graphql-inspector@master
        with:
          schema: 'master:schema.graphql'
```

Now on every commit or every Pull Request, the GraphQL Inspector App will annotate every change,
next to the line in the code where it happened.

<Callout type="info">
  Checks permission needs to be set to write access while running GitHub action.
</Callout>

## Inputs

### `name`

The name of the check (`GraphQL Inspector` by default).

In case of multiple GraphQL Inspector Actions, use `name` to prevent GitHub from overwriting
results. For example, "Check Public API" and "Check Internal API".

```yaml
- uses: graphql-hive/graphql-inspector@master
  with:
    name: Validate Public API
    schema: 'master:public.graphql'

- uses: graphql-hive/graphql-inspector@master
  with:
    name: Check Internal API
    schema: 'master:internal.graphql'
```

### `annotations`

Use annotation (`true` by default).

```yaml
- uses: graphql-hive/graphql-inspector@master
  with:
    schema: 'master:schema.graphql'
    annotations: false
```

### `fail-on-breaking`

Fail on breaking changes (`true` by default).

```yaml
- uses: graphql-hive/graphql-inspector@master
  with:
    schema: 'master:schema.graphql'
    fail-on-breaking: false
```

### `approve-label`

Label to mark Pull Request introducing breaking changes as safe and expected By default, GraphQL
Inspector fails the Pull Request when it detects any breaking changes (`approved-breaking-change` by
default).

```yaml
- uses: graphql-hive/graphql-inspector@master
  with:
    schema: 'master:schema.graphql'
    approve-label: expected-breaking-change
```

To mark the breaking change as safe, apply the `approved-breaking-change` label or define your own
in `approve-label`.

### `endpoint`

Use GraphQL API endpoint as a source of schema. It should represent the "before" schema.

```yaml
- uses: graphql-hive/graphql-inspector@master
  with:
    schema: schema.graphql # important to define a path to schema file, without a branch
    endpoint: 'https://my-app.com/graphql'
```

If you want to use GraphQL API endpoint as source of "after" schema:

```yaml
- uses: graphql-hive/graphql-inspector@master
  with:
    schema: 'https://pr-1234.my-app.dev/graphql'
    endpoint: 'https://my-app.com/graphql'
```

### `rules`

Apply [rules](../essentials/diff#rules) included with the Inspector as well as your own
[custom rules](../essentials/diff#custom-rules)

```yaml
- uses: graphql-hive/graphql-inspector@master
  with:
    schema: 'master:schema.graphql'
    rules: |
      suppressRemovalOfDeprecatedField
      custom-rule.js
```

### `onUsage`

Must be used with the `rules` input. Required to apply the custom logic for the
[`considerUsage`](../essentials/diff#considerusage) rule

```yaml
- uses: graphql-hive/graphql-inspector@master
  with:
    schema: 'master:schema.graphql'
    rules: |
      considerUsage
    onUsage: check-usage.js
```

## Outputs

Read
[GitHub Actions docs](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjobs_idoutputs)
to see how to use outputs.

### `changes`

Total number of changes

![Summary](/assets/img/github/summary.jpg)

![Annotations](/assets/img/cli/github.jpg)
